package nl.jjsoft.airlock.vo 
{
	import nl.jjsoft.airlock.utils.Constants;
	
	[Bindable]
	public class AccountVo 
	{
		public var id:Number;
		public var group_id:Number;
		public var name:String;
		public var url:String = Constants.HTTP_PREFIX;
		public var notes:String;
		
		public var credentials:CredentialsVO = new CredentialsVO();
		
		public function set user_name(value:String):void {
			credentials.user_name = value;
		}		
		
		public function set user_pass(value:String):void {
			credentials.user_pass = value;
		}

		public function toString():String
        {
            return "id: "+ id.toString() + " group_id: " + group_id.toString() + " name: " + name + " url: " + url + " notes: " + notes + " user_name: " + credentials.user_name +" user_pass: " + credentials.user_pass;
        }

		public function appendHttpToUrlIfNotExists():void {
			if (url.indexOf(Constants.HTTP_PREFIX) == -1) {
            	url = Constants.HTTP_PREFIX + url;            		
            }
		}
		
		public function copyValues(other:AccountVo):void {
			this.name = other.name;
			this.url = other.url;
			this.notes = other.notes;
			this.credentials.user_name = other.credentials.user_name;
			this.credentials.user_pass = other.credentials.user_pass;
		}
	}
}